package cc.magicjson.example.demo.task.optional;

import java.util.Comparator;

public class PriorityTaskComparator implements Comparator<Runnable> {
	private final SchedulingStrategy strategy;

	public PriorityTaskComparator(SchedulingStrategy strategy) {
		this.strategy = strategy;
	}

	@Override
	public int compare(Runnable r1, Runnable r2) {
		PriorityScheduledTask t1 = (PriorityScheduledTask) r1;
		PriorityScheduledTask t2 = (PriorityScheduledTask) r2;
		return strategy.compare(t1, t2);
	}
}

